
import 'dart:async';

import 'package:flutter/material.dart';

class SplashScreen extends StatefulWidget {
  @override
  _SplashScreenState createState() => new _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  late Timer _timer;

  startTime() async {
    //设置启动图生效时间
    var _duration = new Duration(seconds: 3);
    _timer = new Timer(_duration, navigationPage);
    return _timer;
  }

  void navigationPage() {
    _timer.cancel();
     Navigator.of(context).pushNamedAndRemoveUntil('/calculator', (Route<dynamic> route) => false);
  }

  @override
  void initState() {
    super.initState();
    startTime();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new ConstrainedBox(
        constraints: BoxConstraints.expand(),
        child: new Image.network(
          "https://img1.baidu.com/it/u=2925488042,873076792&fm=253&fmt=auto&app=138&f=JPEG?w=450&h=780",
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}